import Taro, { Component } from '@tarojs/taro'
import { View, Image } from '@tarojs/components'
import allExtrance from './../../config/allExtrance'
import './modal.less'

class Modal extends Component {
    constructor(props) {
        super(props)
        this.state = {
        }
    }


    componentWillReceiveProps(nextProps) {
        console.log(nextProps.counter, "nextprops")
    }

    componentDidMount() {

    }

    componentWillUnmount() { }

    componentDidShow() { }

    componentDidHide() { }

    exitModal(){
        this.props.onExitModal()
    }

    confirm(){
        this.props.onConfirm()
    }

    stopPropagation(e) {
        e.stopPropagation()
    }

    render() {
        let {modalInfo} = this.props
        return (
            <View className='index'>
                <View className='modal'>
                    <View className='zhezhao' onClick={this.exitModal.bind(this)}>
                        <View className='close'>
                            <Image className='closeImg' src='https://file.open.banchengyun.com/2019/05/30/155919920015964.png'></Image>
                        </View>
                        <View className='infoBlock' onClick={this.stopPropagation.bind(this)}>
                            <Image src='https://file.open.banchengyun.com/2019/05/30/155919814381308.png' className='tiImg'></Image>
                            <View className='infoTitle'>{modalInfo.title}</View>
                            {modalInfo.conSec && <View className='infoConSec'>{modalInfo.conSec}</View>}
                            {modalInfo.conOne && <View className='infoConOne'>{modalInfo.conOne}</View>}
                            <View className='btnBlock'>
                                <View className='item'>
                                    <View className='btnMy cancel' onClick={this.exitModal.bind(this)}>取消</View>
                                </View>
                                <View className='item'>
                                    <View className='btnMy confirm' onClick={this.confirm.bind(this)} style={`background-color:${Taro.getStorageSync('baseColor')}`}>{modalInfo.btnInfo}</View>
                                </View>
                            </View>
                        </View>
                    </View>
                </View>
            </View>
        )
    }
}

export default Modal
